package object3;

/**
 * 抽象类练习
 */
public class AbstractExercise01 {

    public static void main(String[] args) {
        /*
            编写一个Employee类，声明为抽象类，包含如下三个属性：name id salary。
            提供必要的构造器和抽象方法：work()。对于Manager类来说，他既是员工，还具有奖金(bonus)的属性
            请使用继承的思想，设计CommonEmployee类和Manager类，要求类中提供必要的方法进行属性访问，实现 work()
            提示"经理/普通员工 名字 工作中..." OOP的继承 + 抽象类
         */

        Manager manager = new Manager("张三", "1", 5000.0);
        manager.setBonus(1000.0);
        manager.work();

        CommonEmployee tom = new CommonEmployee("tom", "888", 20000);
        tom.work();

    }
}

abstract class Employee {

    private String name;

    private String id;

    private double salary;

    public Employee(String name, String id, double salary) {
        this.name = name;
        this.id = id;
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    //将work做成一个抽象方法
    public abstract void work();

}

class Manager extends Employee{

    private double bonus;

    public Manager(String name, String id, double salary) {
        super(name, id, salary);
    }

    public double getBonus() {
        return bonus;
    }

    public void setBonus(double bonus) {
        this.bonus = bonus;
    }

    @Override
    public void work() {
        System.out.println("经理 " + this.getName() + "工作中...");
    }
}

class CommonEmployee extends Employee{

    public CommonEmployee(String name, String id, double salary) {
        super(name, id, salary);
    }

    @Override
    public void work() {
        System.out.println("普通员工 " + this.getName() + "工作中...");
    }
}